<%@ page import="pojo.User" %><%--
  Created by IntelliJ IDEA.
  User: LW
  Date: 2022/10/30
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="service.impl.NserviceImpl" %>
<%@ page import="pojo.News" %>
<%@ page import="java.util.List" %>
<html>
<head>
    <title>XX新闻</title>
    <script src="asset/js/jquery-3.6.1.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
    <script src="asset/js/axios-0.18.0.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-p1KAotb3W9ndluCsqePPYnjRm3c6abdnIjo0tQwYUv83VsbsYd43RuofnFAaDo0E" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-E5Sj1saJVFNzWWK3YIJB4LEDEEVEGaOdfmCprPDkfWUo+xkb6Ep52Q1TMEtgcFwi" crossorigin="anonymous"></script>

</head>
<body>
<%
    NserviceImpl nservice=new NserviceImpl();
    User user=null;
    List<News> newsList=nservice.NewsSelectBytime();
    List<News> newsListByV=nservice.NewsSelectByV();
    try{
        user= (User) request.getSession().getAttribute("user");
    }catch (Exception e){

    }
    session.setAttribute("user",user);
    session.setAttribute("newsList",newsList);
    session.setAttribute("newsListByV",newsListByV);
%>
<ul class="nav nav-pills" >
    <li role="presentation"  style="padding-right: 30px"><a href="index.jsp">主页</a></li>
    <li role="presentation"  style="padding-right: 40px"><a href="https://new.qq.com/ch/ent/">娱乐</a></li>
    <li role="presentation"  style="padding-right: 40px"><a href="https://new.qq.com/ch/sports/">体育</a></li>
    <li role="presentation"  style="padding-right: 40px"><a href="https://new.qq.com/ch/milite/">军事</a></li>
    <li role="presentation"  style="padding-right: 40px"><a href="https://new.qq.com/ch/tech/">科技</a></li>
    <li role="presentation"  style="padding-right: 40px"><a href="https://new.qq.com/ch/finance/">财经</a></li>
    <c:if test="${user.name==null}">
        <li role="presentation" style="float: right"><a href="lesson6/login1.jsp">登录</a></li>
    </c:if>
    <c:if test="${user.name!=null}">
        <li role="presentation" style="float: right;padding-right: 30px"><a id="out">退出系统</a></li>
        <li role="presentation" style="float: right;padding-right: 30px"><a data-target="#myModal" data-toggle="modal">${user.name}</a></li>
        <li role="presentation" style="float: right;padding-right: 30px"><a data-target="#myModal1" data-toggle="modal">发布新闻</a></li>
    </c:if>
    <c:if test="${user.permissions==888}">
        <li role="presentation" style="float: right"><a href="lesson12/userlist.html">用户管理</a></li>
        <li role="presentation" style="float: right"><a href="lesson12/newlist.html">新闻管理</a></li>
    </c:if>

        <div style="display: none">
            <input name="id" id="uid" value="${user.id}">
        </div>

</ul>

<!--模态表单-->
<div class="modal fade"  id="myModal" aria-labelledby="myModallabel" aria-hidden="true" tabindex="-1" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title" id="myModallabel">用户信息</h5>
            </div>
            <form id="formData" class="form-horizontal" action="http://localhost:8080/01_46_luowei_war/user/upplus">
                <div class="modal-body">
                    <div class="form-group" style="display: none">
                        <label class="control-label col-lg-2">id：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="id" value="${user.id}" name="id" class="form-control" id="id" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">用户名：</label>
                        <div class="col-lg-9">
                            <input type="text" value="${user.usersname}" name="username" placeholder="username" class="form-control" disabled="disabled" id="username"></br>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">密码：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="password" value="${user.password}" name="password" class="form-control" id="password">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">姓名：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="name" value="${user.name}" name="name" class="form-control" id="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">工作：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="work" value="${user.work}" name="work" class="form-control" id="work">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">兴趣：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="interest" value="${user.interest}" name="interest" class="form-control" id="interest">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">性别：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="sex" value="${user.sex}" name="sex" class="form-control" id="sex">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">说明：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="remark" value="${user.remark}" name="remark" class="form-control" id="remark">
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button class="btn btn-default" type="button" data-dismiss="modal" id="closs">关闭</button>
                    <button class="btn btn-success" type="button" > <a href="javascript:subToHX()"> 提交</a></button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade"  id="myModal1" aria-labelledby="myModallabel1" aria-hidden="true" tabindex="-1" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title" id="myModallabel1">发布新闻</h5>
            </div>
            <form id="formData1" method="post" class="form-horizontal" enctype="multipart/form-data" action="http://localhost:8080/01_46_luowei_war/upload.do" >
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-lg-2">标题：</label>
                        <div class="col-lg-9">
                            <input type="text"  name="title" placeholder="title" class="form-control"  id="title"></br>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">作者：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="author" value="${user.name}" name="author" class="form-control" id="author" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">类型：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="category"  name="category" class="form-control" id="category">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">内容：</label>
                        <div class="col-lg-9">
                            <input type="text" placeholder="content"  name="content" class="form-control" id="content">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-lg-2">图片：</label>
                        <div class="col-lg-9">
                            <input type="file" placeholder="img"  name="img" class="form-control" id="img">
                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button class="btn btn-default" type="button" data-dismiss="modal" >关闭</button>
                    <button class="btn btn-success" type="button" > <a href="javascript:subToHX1()"> 提交</a></button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--模态表单-->
<!--巨幕-->
<div class="jumbotron" style="background-image: url('asset/img/1.png')">
    <div class="container">
        <h1>XX新闻网</h1>
    </div>
</div>
<!--巨幕-->
<!-- 列表组-->
<%--<div class="list-group" style="width:50%">--%>
<%--    <a href="#" class="list-group-item active">--%>
<%--        今日要闻--%>
<%--    </a>--%>
<%--    <c:forEach items="${newsList}" var="news" varStatus="row">--%>
<%--        <a href="lesson6/newsmain.jsp?id=${news.id}" class="list-group-item">标题：${news.title}&nbsp; 作者：${news.author}</a>--%>
<%--    </c:forEach>--%>

<%--</div>--%>
<%--<ul class="list-group" style="width: 46%">--%>
<%--    <h4> 最近热点</h4>--%>
<%--    <c:forEach items="${newsList}" var="news" varStatus="row">--%>
<%--        <li class="list-group-item">--%>
<%--            <span class="badge">${news.view_count}</span>--%>
<%--            ${news.title}--%>
<%--        </li>--%>
<%--    </c:forEach>--%>
<%--</ul>--%>
<div class="row">
    <div class="dual-list list-left col-md-5">
        <div class="well text-right">
            <ul class="list-group">
                <h2 style="text-align: center">最新资讯</h2>
        <c:forEach items="${newsList}" var="news" varStatus="row">
                <li class="list-group-item"><a href="lesson6/newsmain.jsp?id=${news.id}" class="list-group-item" style="text-align: center">${news.title}&nbsp; <span class="badge">${news.create_time}</span></a></li>
        </c:forEach>
            </ul>
        </div>
    </div>

    <div class="dual-list list-right col-md-5" style="float: right">
        <div class="well">
            <ul class="list-group">
                <h2 style="text-align: center">最近热点</h2>
                <c:forEach items="${newsListByV}" var="news" varStatus="row">
                    <li class="list-group-item"><a href="lesson6/newsmain.jsp?id=${news.id}" class="list-group-item" style="text-align: center"><span class="badge">${news.view_count}</span>${news.title}&nbsp; </a></li>
                </c:forEach>
            </ul>
        </div>
    </div>
</div>
<!-- 列表组-->

<!-- 缩略图-->

<!-- 缩略图-->

<script>

    $("#out").click(function () {
        <% session.invalidate();%>
        window.location.href="index.jsp";
    });

    function subToHX(){
        document.getElementById("formData").submit();
    }
    function subToHX1(){
        document.getElementById("formData1").submit();
    }
</script>
</body>
</html>
